#include "tcpsocket.h"
#include "impltcpsocket.h"

TcpSocket::TcpSocket()
    : d(new Impl)
{

}

TcpSocket::~TcpSocket()
{

}

int TcpSocket::startup()
{
    return Impl::startup();
}

int TcpSocket::cleanup()
{
    return Impl::cleanup();
}

void TcpSocket::setReadBufferSize(unsigned int size)
{
    d->setBufferSize(size);
}

unsigned int TcpSocket::readBufferSize() const
{
    return d->readBufferSize();
}

bool TcpSocket::connectToHost(std::string host, unsigned short port)
{
    return d->connectToHost(host, port);
}

void TcpSocket::abort()
{
    d->abort();
}

bool TcpSocket::state() const
{
    return d->state();
}

int TcpSocket::write(const char *data)
{
    return write(data, strlen(data));
}

int TcpSocket::write(const char *data, int len)
{
    return d->write(data, len);
}

int TcpSocket::write(const std::string &data)
{
    return write(data.c_str(), data.size());
}

unsigned int TcpSocket::read(char *data, unsigned int maxlen)
{
    return d->read(data, maxlen);
}

std::string TcpSocket::read(unsigned int maxlen)
{
    return d->read(maxlen);
}

std::string TcpSocket::readAll()
{
    return d->readAll();
}

unsigned int TcpSocket::bytesAvailable() const
{
    return d->bytesAvailable();
}

bool TcpSocket::isReadyRead() const
{
    return d->isReadyRead();
}

bool TcpSocket::waitForReadyRead(int msecs)
{
    return d->waitForReadyRead(msecs);
}

void TcpSocket::registerReadyReadSig(std::function<void ()> callback)
{
    d->registerReadyReadSig(callback);
}
